local Entity={Id,Components={}}

function Entity:new(o)--Entity基类的构造函数
    o=o or {}
    self.__index=self
    setmetatable(o, self)
    return o
end

function Entity:addaComponent(Component)--添加一个Component到该Entity的组件集合中
    assert(Component~=nil, "invalid Component")
    table.insert(self.Components, Component)
end

function Entity:deletefromComponents(Component)--从Entity的组件集合中删掉一个
    assert(Component~=nil, "invalid Component")
    local pos=-1
    for i,traverseComponent in ipairs(self.Components) do
        if(Component==traverseComponent) then
            pos=i
        end
    end
    if(pos==-1) then
        return false
    end
    table.remove(self.Components, pos)
    return true
end

function Entity:setID(world,inputId)--设定一个Entity的ID
   for entity in world.Entities do
       -- statements
       assert(inputId==entity.Id, "already has this ID")
   end
   self.Id=inputId
end
-------------------------------------------------------------------------------------
--下方写Entity--
--[[例如
Entity:new(wallsEntity)
wallsEntity:addaComponent(Position)
wallsEntity:addaComponent(material)
wallsEntity:addaComponent(height)
wallsEntity:setID(10)
]]--
-------------------------------------------------------------------------------------
return Entity